<?php 

class Admin_Helper_OrderAdjustment extends Zend_Controller_Action_Helper_Abstract{
	public function preDispatch(){
        $request = $this->getActionController()->getRequest();
        if($request->isPost() && $request->getPost('adjustOrder')){
        	$data = new stdClass();
        	foreach($request->getPost() as $key => $value){
        		$data->$key = $value;
        		if($key == "adjustmentValue")
        			$data->$key *= 100;
//        			This is done because all the money is counted in cents as integers
        	}
        	$result = Doctrine_Model_OrderAdjustments::adjustOrder($data);
        	$result = Doctrine_Model_Orders::adjustTotal($data->orderId); 
        }   
	}
}